﻿@model  Himall.Model.CollocationInfo
<link rel="stylesheet" type="text/css" href="~/Content/bootstrap-datetimepicker.min.css">
<script type="text/javascript" src="~/Scripts/bootstrap-datetimepicker.js"></script>
<script type="text/javascript" src="~/Scripts/bootstrap-datetimepicker.zh-CN.js"></script>
<script type="text/javascript">
    $(function () {
        $("#Title").focus();
        $("#Title").val('组合购');
        $(".start_datetime").val('@DateTime.Now.ToString("yyyy-MM-dd")');

        $(".start_datetime").datetimepicker({
            language: 'zh-CN',
            format: 'yyyy-mm-dd',
            autoclose: true,
            weekStart: 1,
            minView: 2
        });
        $(".end_datetime").datetimepicker({
            language: 'zh-CN',
            format: 'yyyy-mm-dd',
            autoclose: true,
            weekStart: 1,
            minView: 2
        });
        $('.end_datetime').datetimepicker('setEndDate', "@ViewBag.EndTime");
        $('.end_datetime').datetimepicker('setStartDate', $(".start_datetime").val());
        $('.start_datetime').datetimepicker('setStartDate', $(".start_datetime").val());
        $('.start_datetime').datetimepicker('setEndDate', "@ViewBag.EndTime");
        //$(".start_datetime").click(function () {
        //    $('.end_datetime').datetimepicker('show');
        //});
        //$(".end_datetime").click(function () {
        //    $('.start_datetime').datetimepicker('show');
        //});

        $('.start_datetime').on('changeDate', function () {
            if ($(".end_datetime").val()) {
                if ($(".start_datetime").val() > $(".end_datetime").val()) {
                    $('.end_datetime').val($(".start_datetime").val());
                }
            }

            $('.end_datetime').datetimepicker('setStartDate', $(".start_datetime").val());
            //alert($(".start_datetime").val());
        });
        $('.end_datetime').on('changeDate', function () {
            $('.start_datetime').datetimepicker('setEndDate', $(".end_datetime").val());
        });


    });
</script>
<style>
table input[type="text"]{ border:1px solid #ddd; width:64px; padding:0 5px; height:24px; line-height:24px; margin:1px; border-radius:2px;}
table input[readonly]{border: 0;background-color: transparent;}
table p{ line-height:26px;}
table th,table td{ text-align:center;}
</style>
<div class="container">
    <ul class="nav nav-tabs-custom clearfix">
        <strong>组合购</strong>
        <li><a href="./Management">活动管理</a></li>
        <li class="active"><a>新增组合购</a></li>
        <li class=""><a href="./BuyService">购买服务</a></li>
        <em class="primary-btn">
            <span class="glyphicon glyphicon-question-sign"></span>
            <div class="primary">
                <h3>温馨提示：</h3>
                <span>*</span><p>显示店铺已经申请的组合购活动列表</p>
            </div>
        </em>
    </ul>
    @using (Html.BeginForm("AddLimitItem", "Collocation", FormMethod.Post, new { id = "form1" }))
    {
        <div class="form-horizontal">
            <div class="form-group">
                <label class="col-sm-2 control-label" for=""><b style="color:red;">*</b>活动标题：</label>
                <div class="col-sm-3">@Html.EditorFor(item => item.Title, new { htmlAttributes = new { @class = "form-control input-sm" } }) </div>
                <div class="col-sm-5"><span class="help-default">活动标题是商家对组合购活动的别名.</span></div>

            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label" for=""><b style="color:red;">*</b>主商品：</label>
                <div class="col-sm-3"><a class="btn btn-primary btn-sm" id="SelectProduct"><span class="glyphicon glyphicon-plus-sign"></span>&nbsp; 选择主商品</a></div>
                <input type="hidden" id="MainProductId" name="MainProductId" value="" />
            </div>
            <div class="form-group">
                <div class="col-sm-10 col-sm-offset-2" id="mainProducts">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label" for=""><b style="color:red;">*</b>搭配商品：</label>
                <div class="col-sm-3"><a class="btn btn-primary btn-sm" id="SelectOtherProducts"><span class="glyphicon glyphicon-plus-sign"></span>&nbsp; 添加搭配商品</a></div>
                <input type="hidden" id="OtherProductIds" name="OtherProductIds" value="" />
            </div>
            <div class="form-group">
                <div class="col-sm-10 col-sm-offset-2" id="otherProducts">
                </div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label" for=""><b style="color:red;">*</b>开始时间：</label>
				<div class="col-sm-3">@Html.EditorFor(item => item.StartTime, new { htmlAttributes = new { @class = "form-control input-sm start_datetime" } })</div>
				<div class="col-sm-5"><span class="help-default">开始时间必填.</span></div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label" for=""><b style="color:red;">*</b>结束时间：</label>
				<div class="col-sm-3">@Html.EditorFor(item => item.EndTime, new { htmlAttributes = new { @class = "form-control input-sm end_datetime" } })</div>
				<div class="col-sm-5"><span class="help-default">结束时间必须晚于开始时间.</span></div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label" for=""><b style="color:red;"></b>组合描述:</label>
				<div class="col-sm-10">@Html.TextAreaFor(item => item.ShortDesc, 4, 50, new { htmlAttributes = new { @class = "form-control input-sm" } })</div>
			</div>
			<div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
					<button type="button" class="btn btn-primary" onclick="PostCollocation()">保存</button><label class="label-inline" for=""><a href="./Management">返回</a></label>
				</div>
			</div>
         </div>
    }
</div>
        <script src="~/Scripts/jquery.himallLinkage.nocreate.js"></script>
        <script src="~/Scripts/jquery.hiMallDatagrid.js"></script>
        <script src="~/Scripts/jquery.ColloproductSelector.js"></script>
        <script type="text/javascript">
            var otherIds = [];
            $(function () {
                $("#SelectProduct").click(function () {
                    $.productSelector.show(null, function (selectedProducts) {
                        $("#MainProductId").val(selectedProducts[0].id);
                        CreateMainSkuTable(selectedProducts);
                    }, 'selleradmin', false);
                });
                $("#SelectOtherProducts").click(function () {
                    if ($("#MainProductId").val() == "") {
                        $.dialog.errorTips('请先选择主商品！');
                        return;
                    }
                    $.productSelector.show(otherIds, function (selectedProducts) {
                        CreateOtherSkuTable(selectedProducts)
                    }, 'selleradmin', true);
                });
            });
        </script>
        <script src="~/Areas/SellerAdmin/Scripts/Collocation.js"></script>
